﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.UI.Views
{
    public class PathMap
    {
        private static string[] symbols = new string[] { "~/", "./", "@Solution/", "@ProgramData/", "#GAC/", "#SYSTEM32/" };
        public static string GetFoldPath(string targetPath)
        {
            for (int index = 0; index < symbols.Length; index++)
            {
                targetPath = targetPath.Replace(symbols[index], GetFoldName(symbols[index]));
            }
            return targetPath;
        }
        public static string GetFoldName(string symbol)
        {
            string foldPath = string.Empty;
            switch (symbol)
            {
                //程序启动目录
                case "~/":
                    foldPath = UIContext.Current.AppStartupPath;
                    break;
                //当前方案文件所在的目录
                case "./":
                    foldPath = UIContext.Current.SolutionDirectory;
                    break;
                //存放方案的目录
                case "@Solution/":
                    break;
                //系统所使用的ProgramdData目录
                case "@ProgramData/":
                    foldPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                    break;
                //gac目录
                case "#GAC/":
                    foldPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Windows) + @"\assembly\";
                    break;
                //系统目录Windows目录
                case "#SYSTEM32/":
                    foldPath = System.Environment.GetFolderPath(Environment.SpecialFolder.System);
                    break;
            }
            if (!string.IsNullOrEmpty(foldPath)&&!foldPath.EndsWith(@"\"))
            {
                foldPath = foldPath + @"\";
            }
            return foldPath;
        }
    }
}
